package com.ctshk.sapp.visa.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.TokenUser;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.visa.dto.visa.VisaOrderCollectionDTO;
import com.ctshk.rpc.visa.req.visa.VisaOrdercollectionConfirmationReq;
import com.ctshk.rpc.visa.req.visa.VisaOrdercollectionReq;
import com.ctshk.rpc.visa.service.IVisaOrderCollectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 收款明细 前端控制器
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-01-28
 */
@RestController
@RequestMapping("/visa-order-collection")
@Api(value="预订中心签证", tags="预订中心签证")
public class VisaOrderCollectionController extends BaseController {
    @DubboReference
    private IVisaOrderCollectionService iVisaOrderCollectionService;


    @ApiOperation(value="付款", notes="付款(陈雷)")
    @OperationLogAnnotation(operModul = OperationLogModel.VISA, operType = OperationLogType.ADD, operTitle = "付款", operDesc = "付款")
    @PostMapping("/save")
    public Result save(@RequestBody @Valid VisaOrdercollectionReq visaOrdercollectionReq) {
        TokenUser user = getCurrentUser(getRequest());
        return Result.success(iVisaOrderCollectionService.add(visaOrdercollectionReq,user));
    }

    @ApiOperation(value="收款记录", notes="收款记录(陈雷)")
    @OperationLogAnnotation(operModul = OperationLogModel.VISA, operType = OperationLogType.ADD, operTitle = "付款", operDesc = "付款")
    @PostMapping("/list")
    public Result<List<VisaOrderCollectionDTO>> list(@RequestBody @Valid VisaOrdercollectionReq visaOrdercollectionReq) {
        return iVisaOrderCollectionService.list(visaOrdercollectionReq);
    }

    @ApiOperation(value="再次确认", notes="再次确认(陈雷)")
    @OperationLogAnnotation(operModul = OperationLogModel.VISA, operType = OperationLogType.ADD, operTitle = "付款", operDesc = "付款")
    @PostMapping("/confirmation")
    public Result<Long> confirmation(@RequestBody @Valid VisaOrdercollectionConfirmationReq confirmationReq,TokenUser user) {
        return iVisaOrderCollectionService.confirmation(confirmationReq,user);
    }
}
